package com.awesome.imagedemo.scale;

import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.app.ActivityOptionsCompat;

import com.awesome.imagedemo.R;
import com.awesome.sdk.util.ShowLogUtil;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.target.CustomTarget;
import com.bumptech.glide.request.transition.Transition;

import org.jetbrains.annotations.NotNull;

import java.io.File;

/**
 * Created by Gloomy on 2017/6/12.
 */

public class ZoomActivity extends AppCompatActivity {
    LinearLayout mllContainer;
    ZoomImageView mZoomImageView;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_anim);
        mllContainer = findViewById(R.id.ll_container);
        mZoomImageView = findViewById(R.id.zoom_imageview);
//        mllContainer.setOnTouchListener(new View.OnTouchListener() {
//            @Override
//            public boolean onTouch(View v, MotionEvent event) {
//                ShowLogUtil.info("onTouch");
//                LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) mZoomImageView.getLayoutParams();
//                layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
//                layoutParams.height = LinearLayout.LayoutParams.MATCH_PARENT;
//                mZoomImageView.setLayoutParams(layoutParams);
//                return true;
//            }
//        });
//        mZoomImageView.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                ShowLogUtil.info("mZoomImageView");
//                ViewGroup.LayoutParams layoutParams = mZoomImageView.getLayoutParams();
//                layoutParams.width = ViewGroup.MarginLayoutParams.WRAP_CONTENT;
//                layoutParams.height = ViewGroup.MarginLayoutParams.WRAP_CONTENT;
//                mZoomImageView.setLayoutParams(layoutParams);
//            }
//        });
        File gif = new File("/storage/emulated/0/DCIM/maopao/2021-12-13_16-34-15_1639384455576.gif");
        Bitmap bitmap = BitmapFactory.decodeFile(gif.getAbsolutePath());
        LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) mZoomImageView.getLayoutParams();
        layoutParams.width = bitmap.getWidth();
        layoutParams.height = bitmap.getHeight();
        mZoomImageView.setLayoutParams(layoutParams);
        mZoomImageView.requestLayout();
        Glide.with(this)
                .load(gif)
                .into(mZoomImageView);
    }
}
